from tkinter import *
from tkinter.colorchooser import askcolor


def setBgcolor():
    (triple, hexstr) = askcolor()
    if hexstr:
        print(hexstr)
        push.config(bg=hexstr)


root = Tk()
root.title('colorSet')
push = Button(root, text='Set background color', command=setBgcolor)
push.config(height=3, font=('times', 20, 'bold'))
push.pack()
root.mainloop()
